from django.db import models
from simcat.models import Reference
from simcat.datatypes import CARDINALITY_OPTIONS, DATATYPE_OPTIONS

CHARACTERIZABLE_TYPE = (('process', 'Target process'),
                        ('object', 'Target object'),
                        ('representation', 'Representation object'))


class CharacterizableType(models.Model):
    characterization_type = models.CharField(max_length=16, 
                                             choices=CHARACTERIZABLE_TYPE)

    name = models.CharField(max_length=128)
    description = models.TextField(null=True, blank=True)
    reference = models.ManyToManyField(Reference, null=True, blank=True)
    real_objid = models.CharField(max_length=256, null=True, blank=True)
    multiplicity = models.PositiveIntegerField(null=True, blank=True)

    class Meta:
	app_label = "simcat"

class Property(models.Model):
    characterized_object = models.ForeignKey(CharacterizableType)
    name = models.CharField(max_length=128)
    description = models.TextField(null=True, blank=True)
    reference = models.ManyToManyField(Reference, null=True, blank=True)
    datatype = models.CharField(max_length=16, choices=DATATYPE_OPTIONS)
    cardinality = models.CharField(max_length=16, choices=CARDINALITY_OPTIONS)

    class Meta:
	app_label = "simcat"
